<template>
  <div class="AiButton" @click="clickBtn">
    <div class="AiButtonBox">
      <div class="AiButtonBoxText">
        <slot></slot>
      </div>
    </div>
    <div class="AiButtonBg"></div>
  </div>
</template>
<script setup>
let emit =   defineEmits(['click'])


function clickBtn(){
  emit('click')
}

</script>

<style scoped lang="scss">
.AiButton {
  user-select: none;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 30px;
  padding: 2px;
  transition: 0.2s;
  box-shadow: 0 0 5px rgba(19, 141, 255,0.3);
  &:hover {
    box-shadow: 0 0 10px rgba(19, 141, 255, 0.6);
    transform: scale(1.02);    // 轻微放大文字容器
    .AiButtonBg {
      animation-duration: 1s; // 加快背景旋转速度
      filter: brightness(1.2);   // 增加背景亮度
    }

  }
  &:active {
    box-shadow: 0 0 20px rgba(19, 141, 255, 0.6);
    transform: scale(0.9);

    .AiButtonBg {
      animation-duration: 0.8s; // 加快背景旋转速度
      filter: brightness(1.3);   // 增加背景亮度
    }
  }
  .AiButtonBox {
    cursor: pointer;
    border-radius: 30px;
    background-color: #fff;
    width: 100%;
    height: 100%;
    padding: 3px 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 1;
    position: relative;

    .AiButtonBoxText {

      // 彩色文字实现
      color: transparent;
      background-clip: text;
      -webkit-background-clip: text;
      background-image: linear-gradient(138deg,
          #0099ff 37.5%, /* 亮蓝色 */
          #3366ff 50%, /* 电光蓝 */
          #6633ff 62.5%, /* 紫蓝色 */
          #9933ff 75%, /* 亮紫色 */
          #cc00ff 87.5%, /* 电光紫 */
          #ff00ff 100%); /* 洋红色 */
    }

  }

  .AiButtonBg {
    z-index: 0;
    position: absolute;
    width: 120%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg,
        #00ffff 0%, /* 青色 */
        #00ffcc 12.5%, /* 青绿色 */
        #00ccff 25%, /* 天蓝色 */
        #0099ff 37.5%, /* 亮蓝色 */
        #3366ff 50%, /* 电光蓝 */
        #6633ff 62.5%, /* 紫蓝色 */
        #9933ff 75%, /* 亮紫色 */
        #cc00ff 87.5%, /* 电光紫 */
        #ff00ff 100%); /* 洋红色 */
    animation: AiButtonBgRotate 2s linear infinite;
  }
}


@keyframes AiButtonBgRotate {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
